<h1>Databases on '<?=MySQL::$host?>'</h1>

<?=HTML::form('newDatabase','db','create')?>
	<div class="database new">
		<h2>New Database</h2>
		<?=HTML::labeledInput('Name', 'dbName')?>
		<?=HTML::submit('Create')?>
	</div>
</form>

<? foreach ( Database::retrieve() as $db ): ?>
<div class="database">
	<h2><?=$db->name?></h2>
	
	<?=HTML::form('delete_'.$db->id, 'db', 'delete', $db->id)?>
		<div class="deleteButton"><?=HTML::submit('Delete')?></div>
	</form>	
	
	<p><?=HTML::a('View database', 'db', 'show', $db->id)?></p>
	
	<? if ( count($db->tables) > 0 ): ?>
		<ul class="tables">
			<? foreach ( $db->tables as $table ): ?>
				<li><?=$table->name?></li>
			<? endforeach; ?>
		</ul>
	<? else: ?>
		<p>No tables found</p>
	<? endif; ?>	
</div>
<? endforeach; ?>
